﻿CREATE VIEW dbo.v_TrackerTransaction
AS
SELECT     dbo.t_TrackerTransaction.ID, dbo.t_Technician.ID + 0 AS TechnicianID, dbo.t_Technician.FirstName + ' ' + dbo.t_Technician.LastName AS Installer, 
                      dbo.ts_TrackerTransactionType.Name + '' AS Action, dbo.t_TrackerRequest.VIN + '' AS VIN, dbo.t_TrackerTransaction.TrackerID + '' AS Tracker, 
                      dbo.t_TrackerTransaction.Amount, dbo.t_TrackerTransaction.StatusID, CONVERT(varchar, dbo.t_TrackerTransaction.DateStamp, 111) AS Date, 
                      dbo.t_TrackerTransaction.Amount AS Sum__Amount, dbo.v_CarInfo.MsID + '' AS MsID, dbo.v_CarInfo.LoanID + 0 AS LoanID, 
                      dbo.t_Branch.Name + '' AS Branch, dbo.t_TrackerRequest.ID + 0 AS TrackerRequestID
FROM         dbo.v_CarInfo RIGHT OUTER JOIN
                      dbo.t_Dealer INNER JOIN
                      dbo.t_TrackerTransaction INNER JOIN
                      dbo.ts_TrackerTransactionType ON dbo.t_TrackerTransaction.TypeID = dbo.ts_TrackerTransactionType.ID INNER JOIN
                      dbo.t_TrackerRequest ON dbo.t_TrackerRequest.ID = dbo.t_TrackerTransaction.TrackerRequestID INNER JOIN
                      dbo.t_Technician ON dbo.t_Technician.ID = dbo.t_TrackerRequest.TechnicianID ON dbo.t_TrackerRequest.DealerID = dbo.t_Dealer.ID INNER JOIN
                      dbo.t_Branch ON dbo.t_Branch.ID = dbo.t_Dealer.BranchID ON dbo.v_CarInfo.VIN = dbo.t_TrackerRequest.VIN

GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane1', @value = N'[0E232FF0-B466-11cf-A24F-00AA00A3EFFF, 1.00]
Begin DesignProperties = 
   Begin PaneConfigurations = 
      Begin PaneConfiguration = 0
         NumPanes = 4
         Configuration = "(H (1[40] 4[20] 2[20] 3) )"
      End
      Begin PaneConfiguration = 1
         NumPanes = 3
         Configuration = "(H (1[50] 4[25] 3) )"
      End
      Begin PaneConfiguration = 2
         NumPanes = 3
         Configuration = "(H (1[50] 2[25] 3) )"
      End
      Begin PaneConfiguration = 3
         NumPanes = 3
         Configuration = "(H (4 [30] 2 [40] 3))"
      End
      Begin PaneConfiguration = 4
         NumPanes = 2
         Configuration = "(H (1[56] 3) )"
      End
      Begin PaneConfiguration = 5
         NumPanes = 2
         Configuration = "(H (2 [66] 3))"
      End
      Begin PaneConfiguration = 6
         NumPanes = 2
         Configuration = "(H (4[50] 3) )"
      End
      Begin PaneConfiguration = 7
         NumPanes = 1
         Configuration = "(V (3))"
      End
      Begin PaneConfiguration = 8
         NumPanes = 3
         Configuration = "(H (1[56] 4[18] 2) )"
      End
      Begin PaneConfiguration = 9
         NumPanes = 2
         Configuration = "(H (1[52] 4) )"
      End
      Begin PaneConfiguration = 10
         NumPanes = 2
         Configuration = "(H (1[66] 2) )"
      End
      Begin PaneConfiguration = 11
         NumPanes = 2
         Configuration = "(H (4 [60] 2))"
      End
      Begin PaneConfiguration = 12
         NumPanes = 1
         Configuration = "(H (1) )"
      End
      Begin PaneConfiguration = 13
         NumPanes = 1
         Configuration = "(V (4) )"
      End
      Begin PaneConfiguration = 14
         NumPanes = 1
         Configuration = "(V (2))"
      End
      ActivePaneConfig = 1
   End
   Begin DiagramPane = 
      Begin Origin = 
         Top = 0
         Left = 0
      End
      Begin Tables = 
         Begin Table = "v_CarInfo"
            Begin Extent = 
               Top = 568
               Left = 766
               Bottom = 825
               Right = 918
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t_Dealer"
            Begin Extent = 
               Top = 244
               Left = 783
               Bottom = 353
               Right = 941
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t_TrackerTransaction"
            Begin Extent = 
               Top = 89
               Left = 99
               Bottom = 274
               Right = 348
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "ts_TrackerTransactionType"
            Begin Extent = 
               Top = 22
               Left = 520
               Bottom = 116
               Right = 766
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t_TrackerRequest"
            Begin Extent = 
               Top = 319
               Left = 352
               Bottom = 518
               Right = 597
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t_Technician"
            Begin Extent = 
               Top = 395
               Left = 757
               Bottom = 504
               Right = 908
            End
            DisplayFlags = 280
            TopColumn = 0
         End
         Begin Table = "t_Branch"
            Begin Extent = 
               Top = 87
               Left = 975
               Bottom = 196
               Right = 11', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_TrackerTransaction';


GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPane2', @value = N'76
            End
            DisplayFlags = 280
            TopColumn = 0
         End
      End
   End
   Begin SQLPane = 
      PaneHidden = 
   End
   Begin DataPane = 
      Begin ParameterDefaults = ""
      End
      Begin ColumnWidths = 14
         Width = 284
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1890
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
         Width = 1500
      End
   End
   Begin CriteriaPane = 
      Begin ColumnWidths = 11
         Column = 5715
         Alias = 1875
         Table = 2475
         Output = 720
         Append = 1400
         NewValue = 1170
         SortType = 1350
         SortOrder = 1410
         GroupBy = 1350
         Filter = 1350
         Or = 1350
         Or = 1350
         Or = 1350
      End
   End
End', @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_TrackerTransaction';


GO
EXECUTE sp_addextendedproperty @name = N'MS_DiagramPaneCount', @value = 2, @level0type = N'SCHEMA', @level0name = N'dbo', @level1type = N'VIEW', @level1name = N'v_TrackerTransaction';

